<?xml version="1.0" encoding="UTF-8"?>
<as:AppSchemaDataAccess xmlns:as="http://www.geotools.org/app-schema"
	xmlns:ogc="http://www.opengis.net/ogc" xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.geotools.org/app-schema AppSchemaDataAccess.xsd
                      http://www.opengis.net/ogc http://schemas.opengis.net/filter/1.1.0/expr.xsd">
	<namespaces>
		<Namespace>
			<prefix>gsml</prefix>
			<uri>urn:cgi:xmlns:CGI:GeoSciML:2.0</uri>
		</Namespace>
		<Namespace>
			<prefix>gml</prefix>
			<uri>http://www.opengis.net/gml</uri>
		</Namespace>
		<Namespace>
			<prefix>xlink</prefix>
			<uri>http://www.w3.org/1999/xlink</uri>
		</Namespace>
		<Namespace>
			<prefix>sa</prefix>
			<uri>http://www.opengis.net/sampling/1.0</uri>
		</Namespace>
	</namespaces>
	<sourceDataStores>
		<DataStore>
			<id>Borehole</id>
			<parameters>
				<Parameter>
					<name>directory</name>
					<value>file:./</value>
				</Parameter>
			</parameters>
		</DataStore>
	</sourceDataStores>
	<targetTypes>
		<FeatureType>
			<schemaUri>http://www.geosciml.org/geosciml/2.0/xsd/geosciml.xsd</schemaUri>
		</FeatureType>
	</targetTypes>
	<typeMappings>
		<FeatureTypeMapping>
			<sourceDataStore>Borehole</sourceDataStore>
			<sourceType>Borehole</sourceType>
			<targetElement>gsml:Borehole</targetElement>
			<groupBy />
			<attributeMappings>
				<AttributeMapping>
					<targetAttribute>gsml:Borehole</targetAttribute>					
					<idExpression>
                        <OCQL>ID</OCQL>
                    </idExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gml:name[1]</targetAttribute>
					<sourceExpression>
						<OCQL>DH_NAME</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:dateOfDrilling</targetAttribute>
					<sourceExpression>
						<OCQL>DRILLED_DATE</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:drillingMethod</targetAttribute>
					<sourceExpression>
						<OCQL>DRILL_METHOD</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:startPoint</targetAttribute>
					<sourceExpression>
						<OCQL>'natural ground surface'</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:inclinationType</targetAttribute>
					<sourceExpression>
						<OCQL>if_then_else(equalTo(parseInt(DECLIN_FROM_HORIZ),-90),'vertical',if_then_else(equalTo(parseInt(DECLIN_FROM_HORIZ),0),'horizontal',if_then_else(lessThan(parseInt(DECLIN_FROM_HORIZ),0),'inclined down','inclined up')))
					</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:coreCustodian</targetAttribute>
					<ClientProperty>
						<name>xlink:role</name>
						<value>'http://www.geosciml.org/geosciml/2.0/doc/GeoSciML/Borehole/BoreholeDetails.html#coreCustodian'</value>
					</ClientProperty>
					<ClientProperty>
						<name>xlink:href</name>
						<value>'http://www.opengis.net/def/nil/OGC/0/unknown'</value>
					</ClientProperty>
					<ClientProperty>
						<name>xlink:title</name>
						<value>'CSIRONR'</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:coredInterval/gml:Envelope</targetAttribute>
					<ClientProperty>
						<name>axisLabels</name>
						<value>'core envelope'</value>
					</ClientProperty>
					<ClientProperty>
						<name>srsDimension</name>
						<value>'1'</value>
					</ClientProperty>
					<ClientProperty>
						<name>srsName</name>
						<value>strConcat('#',SHAPE_ID)</value>
					</ClientProperty>
					<ClientProperty>
						<name>uomLabels</name>
						<value>'m'</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>sa:sampledFeature</targetAttribute>
					<ClientProperty>
						<name>xlink:role</name>
						<value>'http://www.geosciml.org/geosciml/2.0/doc/GeoSciML/GeologicUnit/GeologicUnit.html'</value>
					</ClientProperty>
					<ClientProperty>
						<name>xlink:href</name>
						<value>'http://www.opengis.net/def/nil/OGC/0/unknown'</value>
					</ClientProperty>
					<ClientProperty>
						<name>xlink:title</name>
						<value>'unknown'</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:operator</targetAttribute>
					<ClientProperty>
						<name>xlink:role</name>
						<value>'http://www.geosciml.org/geosciml/2.0/doc/GeoSciML/Borehole/BoreholeDetails.html#operator'</value>
					</ClientProperty>
					<ClientProperty>
						<name>xlink:href</name>
						<value>'http://www.opengis.net/def/nil/OGC/0/unknown'</value>
					</ClientProperty>
					<ClientProperty>
						<name>xlink:title</name>
						<value>OPERATOR_NAME</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:coredInterval/gml:Envelope/gml:lowerCorner</targetAttribute>
					<sourceExpression>
						<OCQL>START_DEPTH</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:indexData/gsml:BoreholeDetails/gsml:coredInterval/gml:Envelope/gml:upperCorner</targetAttribute>
					<sourceExpression>
						<OCQL>END_DEPTH</OCQL>
					</sourceExpression>
				</AttributeMapping>

				<AttributeMapping>
					<targetAttribute>gsml:collarLocation/gsml:BoreholeCollar</targetAttribute>
					<idExpression>
						<OCQL>COLLAR_ID</OCQL>
					</idExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:collarLocation/gsml:BoreholeCollar/gsml:location</targetAttribute>
					<sourceExpression>
						<OCQL>GEOM_LOCATION</OCQL>
					</sourceExpression>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>gsml:collarLocation/gsml:BoreholeCollar/gsml:elevation</targetAttribute>
					<sourceExpression>
						<OCQL>ELEVATION</OCQL>
					</sourceExpression>
					<ClientProperty>
						<name>axisLabels</name>
						<value>'Gravity-related height'</value>
					</ClientProperty>
					<ClientProperty>
						<name>srsDimension</name>
						<value>'1'</value>
					</ClientProperty>
					<ClientProperty>
						<name>srsName</name>
						<value>'http://www.opengis.net/gml/srs/epsg.xml#5711'</value>
					</ClientProperty>
					<ClientProperty>
						<name>uomLabels</name>
						<value>'m'</value>
					</ClientProperty>
				</AttributeMapping>
				<AttributeMapping>
					<targetAttribute>sa:shape</targetAttribute>
					<sourceExpression>
						<OCQL>SHAPE</OCQL>
					</sourceExpression>
					<targetAttributeNode>gml:LineStringPropertyType</targetAttributeNode>
				</AttributeMapping>
			</attributeMappings>
		</FeatureTypeMapping>
	</typeMappings>
</as:AppSchemaDataAccess>